/// * 作者: Tao
/// * 日期: 2024/3/20
/// * 时间: 16:56
/// * 描述: 请求结果基类
class RequestResult<T> {
  T data;
  int errorCode;
  String errorMsg;

  RequestResult(this.data, this.errorCode, this.errorMsg);

  factory RequestResult.fromJson(Map<String, dynamic> json) {
    return RequestResult(
      json['data'],
      json['errorCode'],
      json['errorMsg'],
    );
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['data'] = this.data;
    data['errorCode'] = this.errorCode;
    data['errorMsg'] = this.errorMsg;
    return data;
  }

  @override
  String toString() {
    StringBuffer sb = StringBuffer('{');
    sb.write(",\"code\":$errorCode");
    sb.write(",\"msg\":\"$errorMsg\"");
    sb.write(",\"data\":\"$data\"");
    sb.write('}');
    return sb.toString();
  }
}
